
/**********************************************************************************\
** 文件名称: oled.h
** 创建人员: YCG
** 创建日期: 2018-12-25
** 文档描述: 
** 版本代号: V0.1
** 版本说明: 初始版本
\********************************************************************************/
#ifndef __OLED_H_
#define __OLED_H_
#include "main.h"
#include "uart.h"
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif

#ifndef SWAP
#define SWAP(a, b) { int16_t t = a; a = b; b = t; }
#endif

#define SET_RES_HIGH  LL_GPIO_SetOutputPin(RES_GPIO_Port, RES_Pin);Uprintf("RES_H\r\n");
#define SET_RES_LOW   LL_GPIO_ResetOutputPin(RES_GPIO_Port, RES_Pin);Uprintf("RES_L\r\n");

#define OLED_WIDTH  96
#define OLED_HEIGHT 16
#define OLED_BUF_SIZE (OLED_WIDTH*(OLED_HEIGHT/8)+1)
#define OLED_CMD_SIZE 2

void OLED_Init(void);
void OLED_SendCmd(uint8_t cmd);
void OLED_SetPos(uint8_t x, uint8_t y);
void OLED_Clear(void);
void OLED_Image(void);
void OLED_Char(uint8_t x, uint8_t y, char ch);
void OLED_String(uint8_t x, uint8_t y, char* st);

void OLED_Update(void);

void OLED_DrawPixel(uint8_t x, uint8_t y, uint8_t color);
void OLED_DrawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,uint16_t color);
void OLED_DrawVLine(int16_t x, int16_t y,int16_t h, uint16_t color);
void OLED_DrawHLine(int16_t x, int16_t y,int16_t w, uint16_t color);

void OLED_DrawRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color) ;
void OLED_FillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void OLED_DrawRoundRect(int16_t x, int16_t y, int16_t w,int16_t h, int16_t r, uint16_t color);
void OLED_FillRoundRect(int16_t x, int16_t y, int16_t w,int16_t h, int16_t r, uint16_t color);

void OLED_DrawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);
void OLED_FillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color);

void OLED_DrawCircle(int16_t x0, int16_t y0, int16_t r,uint16_t color);
void OLED_FillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
void OLED_FillCircleHelper(int16_t x0, int16_t y0, int16_t r,uint8_t cornername, int16_t delta, uint16_t color);
void OLED_DrawCircleHelper( int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color) ;

void OLED_DrawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color);
void OLED_DrawChar(int16_t x, int16_t y, uint8_t c,  uint16_t color);
void OLED_Printf(int16_t x, int16_t y,char *fmt, ...);
void OLED_UPrintf(int16_t x, int16_t y,char *fmt, ...);
#endif

/********************************End of File************************************/
